feat(cli): print, draw and check the plan an extension compiles - #49
Merged
Conversation
`describePlan` made the plan readable as data; this makes it reachable
without writing code. `vscode-ext-kit plan <entry>` evaluates an extension's
entry module and prints what it registers -- as JSON, as a Mermaid or
Graphviz graph of modules, services and the edges between them, or, with
`--check`, as an exit code and the list of problems preflight found.
The entry module is evaluated with a stand-in for `vscode`, because the real
module only exists inside an extension host. That works because nothing in
this package touches VS Code before `activate`; an extension's own
module-scope code is held to the same rule, which the framework already asks
of it. ESM imports of `vscode` are redirected by a resolution hook, CommonJS
`require('vscode')` -- what a bundled extension does -- by Node's CommonJS
resolver, so both an unbundled entry and a production bundle read the same
way.
The tool lives in `bin/`, outside the runtime core, which may not touch Node.
`verify:package` runs it from the installed tarball against a plan the
throwaway consumer wrote, so the one place the stand-in meets a real install
is checked on every run.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
describePlan(#46) made the plan readable as data. This makes it reachable from a shell:The entry module is the extension's own — ESM source or the CommonJS bundle it ships — and the plan is whatever
defineExtensioncompiled when that module was evaluated. Export the result asapp, or name the export with--export.How it evaluates an extension outside VS Code
vscodeexists only inside an extension host, so the tool evaluates the entry with a stand-in: a proxy that answers every property and does nothing. That is enough because nothing in this package touches VS Code beforeactivate—defineExtensioncompiles the plan and stops — and an extension's module-scope code is held to the same rule by the framework's design. ESM imports are redirected by a module-resolution hook; CommonJSrequire('vscode'), which is what a bundled extension does, by Node's CommonJS resolver. Both paths land on the same stand-in, so a production bundle reads the same way an unbundled entry does.The consequence for authors is the one the framework already asks for: keep VS Code reads inside
activateor a handler. Module-scope code that reads a VS Code value gets a proxy instead of a crash, and the failure surfaces where it belongs — in a real host.Output
describePlanreturns; deterministic, so it can be committed and diffed.Where it lives, and how it is checked
The tool is
bin/vscode-ext-kit.mjs, outsidesrc/, which may not touch Node.verify:packagenow runs it from the installed tarball against a plan written in the throwaway consumer project, so the one place the stand-in meets a real install is exercised on every run. A test suite drives it as a child process across every format and exit code.It was also run against a published extension's real CommonJS bundle, unmodified, and read the plan out of it.
Compatibility
Additive: a
binentry,bin/infiles. No runtime code changes.🤖 Generated with Claude Code